<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class CoinClue extends Model
{
    use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'coin_clue';

    const IS_UNLOCK_YES = 1;
    const IS_UNLOCK_NO = 0;

    const TYPE_TEXT = 1;
    const TYPE_IMAGE = 2;
    const TYPE = [
        self::TYPE_TEXT => '文字',
        self::TYPE_IMAGE => '图片',
    ];

    const IS_CIRCLE_YES = 1;
    const IS_CIRCLE_No = 0;
    const IS_CIRCLE = [
        self::IS_CIRCLE_YES => '动态',
        self::IS_CIRCLE_No => '固定',
    ];

    public function user_coin_clue()
    {
        return $this->hasMany('App\Models\UserCoinClue', 'coin_clue_id');
    }

    public function getContentAttribute($value)
    {
        return $this->type == self::TYPE_IMAGE ? trim(config('filesystems.disks.aliyun.domain'), '/') . '/' . $value : $value;
    }
}
